﻿using System.Web.Mvc;
using CandidateManager.Controllers;
using WI.CandidateManager.Business.Objects;
using admin = WI.CandidateManager.Common.Data.Entities.Admin;

namespace CandidateManager.Areas.Admin.Controllers
{
    public class AdminsController : AutorizeBaseController
    {
        private readonly AdminBO adminBO = new AdminBO();

        // GET: /Admin/Admins/List
        public ActionResult Index()
        {
            return RedirectToAction("List");
        }

        // GET: /Admin/Admins/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: /Admin/Admins/Create
        [HttpPost]
        public ActionResult Create(admin admin)
        {
            adminBO.CreateAdmin(admin);

            return RedirectToAction("List");
        }

        // GET: /Admin/Admins/List
        public ActionResult List()
        {
            return View(adminBO.GetAdminsList());
        }

        // GET: /Admin/Admins/Update/ID
        public ActionResult Update(long id)
        {
            return View(adminBO.GetAdminById(id));
        }

        // POST: /Admin/Admins/Update
        [HttpPost]
        public ActionResult Update(admin admin)
        {
            adminBO.UpdateAdmin(admin);

            return RedirectToAction("List");
        }

        // GET: /Admin/Admins/Delete/ID
        public ActionResult Delete(long id)
        {
            adminBO.DeleteRecord(id);

            return RedirectToAction("List");
        }
    }
}
